﻿using BCCommon;
using BCDto.Common.ErrorMessage;
using BCDto.Common.Payment.PaymentRecord;
using BCService.Common.Payment.PaymentRecord;
using Microsoft.AspNetCore.Mvc;

namespace BCTMSRESTful.Controllers.DriverApp.Wallet
{
    /// <summary>
    /// 交易记录
    /// </summary>
    [ApiExplorerSettings(GroupName = "DriverApp")]
    [Route("api/v1/DriverApp/[controller]")]
    public class PaymentRecordController : DriverAppBaseController
    {
        private readonly ICommonPaymentRecordService commonPaymentRecordService;

        public PaymentRecordController(ICommonPaymentRecordService commonPaymentRecordService)
        {
            this.commonPaymentRecordService = commonPaymentRecordService;
        }

        /// <summary>
        /// 获取用户支付记录细列表
        /// </summary>  
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        /// <response code="200">获取用户支付记录明细列表</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet]
        [ProducesResponseType(typeof(PageableList<PaymentRecordDto>), 200)]
        [ProducesResponseType(typeof(ErrorMessageDto), 400)]
        [ProducesResponseType(typeof(ErrorMessageDto), 500)]
        public IActionResult Get(
            [FromQuery(Name = "index")]int? pageIndex = 1,
            [FromQuery(Name = "size")]int? pageSize = 10)

        {
            return Ok(this.commonPaymentRecordService.GetPaymentRecordsByUserId(pageIndex.Value, pageSize.Value, this.UserInfo.UserId));

        }
    }
}